The present invention relates generally to a computer language interpreter. More particularly, the present invention relates to an interpreter which performs time consuming operations without visibly impacting a user.
Software programs written in a source language and running on a hardware system are said to be interpreted if they are running under the control of a piece of software called an interpreter. An interpreter may execute the program's source language one instruction at a time by fetching, decoding, and reproducing the effects of each source instruction on the machine's state. A faster implementation may dynamically translate entire blocks of source language instructions into blocks of machine code which can be directly executed on the hardware. Such an interpreter is commonly called a dynamic translator.
Some interpreters collect behavioral information, called a profile, used to monitor and analyze the program's run-time behavior. Such profile data is important for translating source code into machine code because the translator can use the data to compile the program to run optimally for a specific hardware. Optimization leads to higher performance of the program. Some modern interpreters can profile the program as they execute it.
A problem can occur when the time comes to dynamically translate the instructions of the program or to process the profile data, both operations can be time consuming. The prior art tries to address the problem of performing time consuming operations in one of two ways. Each method of addressing the problem, however, can result in further problems.
For example, some interpreters immediately perform these time consuming operations as a need arises. In the case of profile data, the interpreter may want to send the data to a file, send the information over a network, or compress the data, all of which can be time consuming. A problem can occur if the program being interpreted is user interactive because the user may notice a pause in the execution of the program while the system performs the operation. For example, if the user is running a word processor and typing on a keyboard, he may notice a delay between the time that he pushes a key on the keyboard and when the character is displayed on the screen. Similarly, if the user is running an animation program on a monitor, a delay, even if very brief, could be easily noticed.
Further, some interpreters only perform time consuming operations when the program terminates. A problem can occur if the program never terminates, such as with a server program. The result is that the program may never be translated, and a run time of an interpreted program can be slow compared to the run time of a translated program. Similarly, while some other interactive programs ultimately terminate, they can execute for long periods of time before the program terminates. Hence, long periods of time will elapse before a compiler can translate the program, and utilize profile information to optimize the program.
Accordingly, in response to the problems discussed above, a primary object of the present invention is to provide an improved method for performing time consuming or heavyweight operations without the user noticing any slowdown in the program.
Another object of the present invention is to provide such an improved method wherein time consuming operations are performed before the program terminates.
A further object of the present invention is to provide such an improved method which is adapted to process profile information and to dynamically translate blocks of the program while the program is executing, without the user noticing any delay in the program execution.